package com.zkthink.zhl.order.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zkthink.base.R;
import com.zkthink.base.controller.SuperController;
import com.zkthink.base.request.PageParams;
import com.zkthink.clh.order.dto.ChlConfigPageDTO;
import com.zkthink.clh.order.dto.ChlConfigSaveDTO;
import com.zkthink.clh.order.dto.ChlConfigUpdateDTO;
import com.zkthink.clh.order.dto.ParameterTypeDto;
import com.zkthink.clh.order.entity.ChlConfig;
import com.zkthink.clh.order.entity.ChlLbt;
import com.zkthink.zhl.order.service.ChlConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.poifs.property.Child;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * 前端控制器
 * 功能价格设置表
 * </p>
 *
 * @author chenke
 * @date 2022-04-24
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/config")
@Api(value = "Config", tags = "功能价格设置表")

public class ChlConfigController extends SuperController<ChlConfigService, Long, ChlConfig, ChlConfigPageDTO, ChlConfigSaveDTO, ChlConfigUpdateDTO> {

    @ApiOperation(value = "添加参数", notes = "添加参数")
    @PostMapping("/addAdminConfig")
    public R addAdminConfig(@RequestBody ChlConfigSaveDTO dto){
        return baseService.addAdminConfig(dto);
    }

    @ApiOperation(value = "编辑参数", notes = "编辑参数")
    @PostMapping("/editAdminConfig")
    public R editAdminConfig(@RequestBody ChlConfig dto){
        return baseService.editAdminConfig(dto);
    }
    @ApiOperation(value = "是否使用", notes = "0=使用 1=不使用")
    @PostMapping("/parameterType")
    public R parameterType(@RequestBody ParameterTypeDto dto){
        return baseService.parameterType(dto);
    }
    @ApiOperation(value = "后台查询参数", notes = "后台查询参数")
    @PostMapping(value = "/findAdminConfig")
    public R<IPage<ChlConfig>> findAdminConfig(@RequestBody PageParams<ChlConfigPageDTO> dto) {
        ChlConfigPageDTO model = dto.getModel();
        IPage page = dto.getPage();
        return R.success(baseService.findAdminConfig(page, model));
    }

    @ApiOperation(value = "后台查询轮播图", notes = "后台查询轮播图")
    @GetMapping(value = "/lbt")
    public R<List<ChlLbt>> lbt() {
        return R.success(baseService.lbt());
    }
    @ApiOperation(value = "后台添加轮播图", notes = "后台添加轮播图")
    @PostMapping(value = "/addlbt")
    public R addlbt(@RequestBody ChlLbt chlLbt) {
        return R.success(baseService.addlbt(chlLbt));
    }
    @ApiOperation(value = "后台删除轮播图", notes = "后台删除轮播图")
    @GetMapping(value = "/deletelbt/{id}")
    public R deletelbt(@PathVariable("id") Long id) {
        return R.success(baseService.deletelbt(id));
    }
}
